/*
	Implement the Comparable interface for the Shape class.

	Compare first by name, then by area if the names are the same.
	If the current instance is greater, return a positive value.
	If the current instance is less, return a negative value.
	If the instances are the same, return 0.
*/

public abstract class Shape /*ans bl*/implements Comparable<Shape>/*ans ab*/
{
	private String _name;

	protected Shape(String name)
	{
		_name = name;

	}// end constructor

	//returns area as defined by sub class that implements this method
	public abstract double area();

	public String toString()
	{
		return "Shape Name: " + _name + "\nArea: "
				+ area() + "\n------------------------";

	}//end toString()

	public String getName()
	{
		return _name;

	}

//***************************************************
// Write your method below
/*ans bl*/
	public int compareTo(Shape other)
	{
		int result = this._name.compareTo(other._name);
		if (result == 0)
		{
			double diff = this.area() - other.area();
			if (diff > 0)
				return 1;
			else if (diff < 0)
				return -1;
			else
				return 0;
		}
		else
			return result;

	}
/*ans ab*/

}//end class Shape